package org.itboys.mobile.dto.count;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.itboys.commons.utils.tools.ListUtil;

import java.math.BigDecimal;
import java.util.List;

/**
 * 作者：jiangxiong
 * 日期：2017年5月8日
 * 描述：圣代_结算（购物车实体，只取products）_dto。
 */

public class SundayCountTotalDto {

    private BigDecimal totalAmount;//应付金额
    private BigDecimal payAmount;//实付金额/实付爱购币
    @JsonIgnore
    private List<Long> cartIds;//购物车ID集合,用户创建订单后删除购车
    List<SundayCountDto> counts;
    //2018年2月4日
    private Integer type;//结算总的类型，只对单一结算有效
    public SundayCountTotalDto() {
    }

    public SundayCountTotalDto(BigDecimal totalAmount, BigDecimal payAmount, List<Long> cartIds, List<SundayCountDto> counts) {
        this.totalAmount = totalAmount;
        this.payAmount = payAmount;
        this.cartIds = cartIds;
        this.counts = counts;
    }

    public BigDecimal getTotalAmount() {
        if(totalAmount!=null)totalAmount=totalAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getPayAmount() {
        if(payAmount!=null)payAmount=payAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
        return payAmount;
    }

    public void setPayAmount(BigDecimal payAmount) {

        this.payAmount = payAmount;
    }


    public List<Long> getCartIds() {
        return cartIds;
    }

    public void setCartIds(List<Long> cartIds) {
        this.cartIds = cartIds;
    }

    public List<SundayCountDto> getCounts() {
        return counts;
    }

    public void setCounts(List<SundayCountDto> counts) {
        this.counts = counts;
    }
    public String getCatIdsStr(){
        StringBuilder sb = new StringBuilder();
        if(ListUtil.isNotNull(cartIds)){
            for(Long cartId:cartIds){
                sb.append(cartId+",");
            }
            return sb.substring(0,sb.length()-1).toString();
        }
        return  null;
    }

    public Integer getType() {
        if(ListUtil.isNotNull(counts)){
            type=counts.get(0).getType();
        }
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }
}
